
typedef struct {
    double mean[5];    // 标准化均值
    double std[5];     // 标准化标准差
    double intercept;  // 截距项
    double coef[5];     // 特征系数 [iTLB, uTLB, m, k, n]
} LogisticModel;

//------------------------- 模型实例 -------------------------
static const LogisticModel model_MkN = {
    .mean = {3.79016367, 85.61310879, 1063.30512249, 40.74832962, 1031.97327394},
    .std = {3.32824544, 75.17919106, 578.32241683, 22.63393993, 616.39388038},
    .intercept = -8.80846136842291,
    .coef = {-1.8581, -1.8581, -0.2568, -1.4007, -7.0804}
};

//------------------------- 预测函数 -------------------------
int Model_Predict(double *input) {
    // 深拷贝输入数据以避免修改原始值
    double features[5];
    // 标准化处理
    features[0] = (input[0] - model_MkN.mean[0]) / model_MkN.std[0];
    features[1] = (input[1] - model_MkN.mean[1]) / model_MkN.std[1];
    features[2] = (input[2] - model_MkN.mean[2]) / model_MkN.std[2];
    features[3] = (input[3] - model_MkN.mean[3]) / model_MkN.std[3];
    features[4] = (input[4] - model_MkN.mean[4]) / model_MkN.std[4];    
    
    // 计算线性部分
    double logit = model_MkN.intercept
             + model_MkN.coef[0] * features[0]
             + model_MkN.coef[1] * features[1]
             + model_MkN.coef[2] * features[2]
             + model_MkN.coef[3] * features[3]
             + model_MkN.coef[4] * features[4];

    // 决策阈值0.881对应概率阈值0.7065
    return (logit >= 0.881) ? 1 : 0;
}